package com.example.spring_xx_u_market;

import com.example.bean.ErrorCodeV;
import com.example.bean.OrderV;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import util.UidCtrl;

import javax.servlet.http.HttpServletRequest;

@Slf4j
@RestController
@RequestMapping("api")

public class OrderVCtrl {
    @PostMapping("order")
    public Object getUserOrder(HttpServletRequest request) {
        String uid = request.getParameter("uid");
        if (uid == null) {
            return new ErrorCodeV("005");
        } else {
            switch (UidCtrl.checkUid(uid)) {
                case "-2":
                    return new ErrorCodeV("003");
                case "-1":
                    return new ErrorCodeV("002");
                case "0":
                    return new ErrorCodeV("004");
                default:
                    return new OrderV(uid);
            }
        }

    }
}
